<template>
  <view class="main">
    <view class="ip-item">
      <view class="text">圈子奉献值：{{ getMemberInfos?.dedication || 0 }}</view>
      <view class="block"></view>
    </view>
    <view class="dispaly-just-between" style="margin-bottom: 20rpx">
      <view class="ip-item" style="width: 48%; margin-bottom: 0">
        <view class="text">分享数：{{ getMemberInfos?.shareNum || 0 }}</view>
      </view>
      <view class="ip-item" style="width: 48%">
        <view class="text">引荐数：{{ getMemberInfos?.pullNum || 0 }}</view>
      </view>
    </view>
    <view class="ip-item" v-if="getMemberInfos?.expireTime">
      <view class="text">到期时间：{{ getMemberInfos?.expireTime }}</view>
      <view class="block"></view>
    </view>
    <view class="ip-item" @click="showPoster = true">
      <input type="text" placeholder="我的邀请卡" disabled placeholder-class="ip" />
      <image src="/static/icon/down.svg" mode="widthFix" />
      <view class="block"></view>
    </view>
    <view class="ip-item" @click="$goUrl(`/pages/circle/pages/updateUser`)">
      <input type="text" placeholder="修改我的信息" disabled placeholder-class="ip" />
      <image src="/static/icon/down.svg" mode="widthFix" />
      <view class="block"></view>
    </view>
    <view class="ip-item" @click="$goUrl(`/pages/circle/pages/importList?id=${Ids}`)">
      <input type="text" placeholder="协助录入" disabled placeholder-class="ip" />
      <image src="/static/icon/down.svg" mode="widthFix" />
      <view class="block"></view>
    </view>
    <view class="ip-item" @click.stop="$goUrl(`/pages/index/pages/businessCard`)">
      <input type="text" placeholder="我的名片/服务" disabled placeholder-class="ip" />
      <image src="/static/icon/down.svg" mode="widthFix" />
      <view class="block"></view>
    </view>
    <view class="ip-item">
      <input type="text" placeholder="接收社区推送" disabled placeholder-class="ip" />
      <view>
        <van-switch active-color="#0753fd" inactive-color="#eeeeee" v-model="checked" @change="change" />
      </view>
    </view>
  </view>
  <!-- 海报 -->
  <!-- <Poster :showPoster="showPoster" /> -->
  <van-popup v-model:show="showPoster" round>
    <view class="pop-main">
      <Poster :circleInfos="circleInfos" />
    </view>
  </van-popup>
</template>

<script lang="tsx" setup>
import Poster from "@/components/poster/poster.vue";
import { ref } from "vue";
import { onLoad } from "@dcloudio/uni-app";
import { getMemberInfo, circleInfo, myProson, setPower } from "@/api/apiList";
const checked = ref(false);
const showPoster = ref(false);
const Ids = ref();
onLoad((e) => {
  if (e && e?.id) {
    Ids.value = e?.id;
    getMemberInfoData(e?.id);
    circleInfoData(e?.id);
  }
});

const change = async (e) => {
  const res = await setPower({ isReceive: e ? 1 : 0, id: getMemberInfos.value.id })
  console.log(e, 'eee')
}

const getMemberInfos = ref();
const getMemberInfoData = async (ids) => {
  const response = await myProson({ circleId: ids });
  if (response && response?.code == 200) {
    getMemberInfos.value = response?.data;
    checked.value = response?.data?.isReceive == 0 ? false : true;
  }
};
const circleInfos = ref();
const circleInfoData = async (ids) => {
  const response = await circleInfo({ id: ids });
  if (response && response?.code == 200) {
    circleInfos.value = response?.data;
  }
};
</script>

<style lang="scss" scoped>
.main {
  padding: 30rpx;
}

.ip {
  color: #000;
}
</style>
